package com.gitee.common.data.tree.node;

import com.gitee.common.data.tree.event.EventHandler;

import java.util.HashSet;
import java.util.Set;

public abstract class AbstractTreeItemNode implements TreeItemNodeI {

    private String id;
    private String name;
    private String type;

    private TreeItemNodeData nodeData;

    private Set<EventHandler> eventHandlers = new HashSet<>();

    @Override
    public String getType() {
        return type;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Override
    public TreeItemNodeData getNodeData() {
        return nodeData;
    }

    public void setNodeData(TreeItemNodeData nodeData) {
        this.nodeData = nodeData;
    }

    @Override
    public int compareTo(TreeItemNodeI o) {
        return o.getId().compareTo(this.id);
    }

    @Override
    public void addEventHandler(EventHandler handler) {
        eventHandlers.add(handler);
    }

    public Set<EventHandler> getEventHandlers() {
        return eventHandlers;
    }
}
